package www.golf.web.util;
//	String[] arlist = pk.split(",");

/***********************************************************************************************************************
 * 蝔��:摮葡頧��賊�class
 * 雿� Allen
 * version 2.0
 * Update: 2003.04.10
 * Copyright: Copyright (c) 2002.09.09
 ***********************************************************************************************************************/
public class strManage{
    /*****************************************************************************************************************
		閫�捱銵Ⅳ��<br>
		撣嗅��豢芋撘�<br>
				str			��摮葡<br>
		�鞈�:String
		PS: 閫�捱銵Ⅳ��,閬B摮����瘙箏��其���.
    ******************************************************************************************************************/
	public static String FStr(String str){
		String str1="",x="",x1="";
	    byte[] z;
		for(int a=0;a<str.length();a++){
			x=str.substring(a,(a+1));
			x1="";
			if((a+3)<str.length()){
				x1=str.substring((a+1),(a+3));
			}
			z=x.getBytes();
			if((z[0]<40) || (z[0]>127)){
				if(z.length==2){
					if(z[1]==92){
						if(x1.equals("\\\\")){
							str1+=x;
						}else{
							str1+=x+"\\\\";
						}
					}else{
						str1+=x;
					}
				}else{
					str1+=x;
				}
			}else{
				str1+=x;
			}
		}
		return str1;
	}

	public static String reChangeString(String str){
		return changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(str,"&#34;","\""),"&#40;","("),"&#41;",")"),"&#42;","*"),"&#43;","+"),"&#60;","<"),"&#62;",">"),"&#63;","?"),"&#91;","["),"&#93;","]"),"&#123;","{"),"&#125;","}");
	}
	
	public static String changeString(String str){
		return changeString(str,true);
	}
	public static String changeString(String str,boolean parseEnter){
		if(str==null || str.trim().length()==0) return "";
		//'������in ('','')��憿�		//��   ',",null,(,),*,+,<,>,?,[,],{,}
		str=changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(changeStr(str,"\"","&#34;"),"null",""),"(","&#40;"),")","&#41;"),"*","&#42;"),"+","&#43;"),"<","&#60;"),">","&#62;"),"?","&#63;"),"[","&#91;"),"]","&#93;"),"{","&#123;"),"}","&#125;");
		//����蝚西�		
		if(parseEnter) str=changeStr(str,(char)(10)+(char)(13),"");		
		//����蝚西�(�︷har13)
		if(parseEnter) str=changeStr(str,(char)(10),"");
		return str;		
	}	
	
	//銝蝙�災aa.replaceAll("(","");��憭畾泵�瘜蝙�典�:(){}[]?\+* ��(char)(13)(char)(10)蝑�銵泵��	
	public static String changeStr(String MainStr,String str1,String str2){//��銝�String
		while(MainStr.indexOf(str1)>-1)	MainStr=MainStr.substring(0,MainStr.indexOf(str1))+str2+MainStr.substring(MainStr.indexOf(str1)+(str1.length()));			
		return MainStr;
	}
	public static String changeStr(String MainStr,char str1,String str2){//��char(10)
		while(MainStr.indexOf(str1)>-1)	MainStr=MainStr.substring(0,MainStr.indexOf(str1))+str2+MainStr.substring(MainStr.indexOf(str1)+1);
		return MainStr;
	}	
	public static String changeStr(String MainStr,int str1,String str2){//��char(13)+char(10)
		while(MainStr.indexOf(str1)>-1)	MainStr=MainStr.substring(0,MainStr.indexOf(str1))+str2+MainStr.substring(MainStr.indexOf(str1)+2);
		return MainStr;
	}	
}